package com.studies.pc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.studies.pc.pojo.ActivityEnroll;
import com.studies.pc.mapper.ActivityEnrollMapper;
import com.studies.pc.query.ActivityEnrollQuery;
import com.studies.pc.service.ActivityEnrollService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.studies.pc.vo.ActivityEnrollVo;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 研学报名 服务实现类
 * </p>
 *
 * @author 研学活动后台
 * @since 2019-12-24
 */
@Service
public class ActivityEnrollServiceImpl extends ServiceImpl<ActivityEnrollMapper, ActivityEnroll> implements ActivityEnrollService {

    @Override
    public Integer enroll(ActivityEnrollQuery activityEnrollQuery) {
        ActivityEnroll activityEnroll=new ActivityEnroll();
        activityEnroll.setActivityId(activityEnrollQuery.getActivityId());
        activityEnroll.setPeopleId(activityEnrollQuery.getPeopleId());
        activityEnroll.setPhoneNumber(activityEnrollQuery.getPhoneNumber());
        activityEnroll.setStatus(true);
        int insert = baseMapper.insert(activityEnroll);
        return insert;

    }

    @Override
    public Boolean enrollName(ActivityEnrollQuery activityEnrollQuery) {
        QueryWrapper<ActivityEnroll> queryQueryWrapper=new QueryWrapper<>();
        queryQueryWrapper.eq("activity_Id",activityEnrollQuery.getActivityId());
        queryQueryWrapper.eq("people_Id",activityEnrollQuery.getPeopleId());
        ActivityEnroll activityEnroll = baseMapper.selectOne(queryQueryWrapper);
        return activityEnroll.getStatus();
    }
}
